package com.dream.keigezhushou.Activity.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.dream.keigezhushou.Activity.Uiutils.StringUtils;
import com.dream.keigezhushou.Activity.Uiutils.UiUtils;
import com.dream.keigezhushou.Activity.kege.acty.SingingDetailActivity;
import com.dream.keigezhushou.Activity.kege.adapter.MyKeAdapter;
import com.dream.keigezhushou.R;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

/**
 * 我的k歌
 */
public class MyKeFragment extends Fragment {
    private PullToRefreshListView mMPullToRefreshListView;
    private ListView mListlv;
    private Intent intent;

    private MyKeAdapter myKeAdapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        //getDataFromService();   获取网络数据并解析
        // 加载动画
        //设置上拉刷新重新请求网络数据  更新adapter?
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mMPullToRefreshListView = (PullToRefreshListView) UiUtils.inflateView(R.layout.kege_fragment);
        mListlv = mMPullToRefreshListView.getRefreshableView();
        myKeAdapter = new MyKeAdapter(getContext());
        mListlv.setAdapter(myKeAdapter);
        initView();
        return mMPullToRefreshListView;
    }


    private void initView(){
        myKeAdapter.setItemOnClickListening(new MyKeAdapter.ItemOnClickListening() {
            @Override
            public void itemClick(int postion) {

                Intent intent = new Intent();
                intent.putExtra(StringUtils.KEGESTATE,"听歌");
                intent.setClass(getContext(), SingingDetailActivity.class);
                startActivity(intent);


            }
        });



    }

    private void initData() {




    }


}
